//
//  ReceiveSucccessVC.m
//  KuWoCan
//
//  Created by hwd on 17/3/15.
//  Copyright © 2017年 hwd. All rights reserved.
//

#import "ReceiveSucccessVC.h"
#import "OrderManageVC.h"
#import "OrderDetailInfoModel.h"

@interface ReceiveSucccessVC ()

@property (nonatomic, strong)OrderDetailInfoModel *model;
@end

@implementation ReceiveSucccessVC

- (instancetype)initWithOrderDetailInfoModel:(OrderDetailInfoModel *)model {
    if (self = [super init]) {
        _model = model;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setUpUI];
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    self.navigationController.interactivePopGestureRecognizer.enabled = NO;
}

- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
    self.navigationController.interactivePopGestureRecognizer.enabled = YES;
}

- (void)setUpUI
{
    self.view.backgroundColor = [UIColor whiteColor];
    __weak typeof(self) weakSelf = self;
    self.title = @"确认收货";

    UIImageView *imgView = [[UIImageView alloc] init];
    imgView.image = kImg(@"car");
    [self.view addSubview:imgView];
    [imgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(weakSelf.view.mas_centerX);
        make.top.equalTo(@30);
        make.size.mas_equalTo(CGSizeMake(250, 200));
    }];

    UILabel *statusLab = [UILabel new];
    statusLab.textColor = [UIColor orangeColor];
    statusLab.font = [UIFont systemFontOfSize:17];
    statusLab.textAlignment = NSTextAlignmentCenter;
    statusLab.text = @"确认收货成功";
    [self.view addSubview:statusLab];
    [statusLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(imgView.mas_bottom).offset(20);
        make.centerX.equalTo(imgView.mas_centerX);
        make.height.equalTo(@17);
    }];

    UILabel *numLab = [UILabel new];
    numLab.textColor = [UIColor grayColor];
    numLab.font = [UIFont systemFontOfSize:14.0];
    numLab.textAlignment = NSTextAlignmentLeft;
    numLab.text = [NSString stringWithFormat:@"订单编号: %@", self.model.orderNumber];
    [self.view addSubview:numLab];
    [numLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(statusLab.mas_bottom).offset(20);
        make.centerX.equalTo(imgView.mas_centerX);
        make.height.equalTo(@14);
    }];

    UILabel *comTimeLab = [UILabel new];
    comTimeLab.textColor = [UIColor grayColor];
    comTimeLab.font = [UIFont systemFontOfSize:14.0];
    comTimeLab.textAlignment = NSTextAlignmentLeft;
    comTimeLab.text = [NSString stringWithFormat:@"提交时间: %@", self.model.createDate];
    [self.view addSubview:comTimeLab];
    [comTimeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(numLab.mas_bottom).offset(10);
        make.centerX.equalTo(imgView.mas_centerX);
        make.height.equalTo(@14);
    }];

    UILabel *sendTimeLab = [UILabel new];
    sendTimeLab.textColor = [UIColor grayColor];
    sendTimeLab.font = [UIFont systemFontOfSize:14.0];
    sendTimeLab.textAlignment = NSTextAlignmentLeft;
    sendTimeLab.text = [NSString stringWithFormat:@"发货时间: %@", self.model.updateDate];
    [self.view addSubview:sendTimeLab];
    [sendTimeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(comTimeLab.mas_bottom).offset(10);
        make.centerX.equalTo(imgView.mas_centerX);
        make.height.equalTo(@14);

    }];
//    需求不显示收货时间
    comTimeLab.hidden = YES;
    sendTimeLab.hidden = YES;
}

- (void)onTapLeftBarButton {
    for (UIViewController *controller in self.navigationController.viewControllers) {
        if ([controller isKindOfClass:[OrderManageVC class]]) {
            OrderManageVC *orderManageVC =(OrderManageVC *)controller;
            [self.navigationController popToViewController:orderManageVC animated:YES];
        }
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
